<%--
  Created by IntelliJ IDEA.
  User: ghost
  Date: 2020/12/16
  Time: 17:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-3.4.1.min.js"></script>
    <script type="text/javascript">
        function returnObject(){
            $.ajax({
                url:"returnParam/returnObject.do",
                data:{
                    name:"chenxiaokuai",
                    age:18
                },
                type:"post",
                dataType:"json",
                success:function (response){
                    alert(response.name + " " + response.age);
                }

            })
        }
        function returnString(){
            $.ajax({
                url:"returnParam/returnStringText.do",
                dataType:"text",
                success:function (response){
                    alert(response);
                }

            })
        }
    </script>
</head>
<body>
    <a href="test/some.do?name=wcy" >发起some.do请求</a>
    <br />
    <form action="test/other.do" method="post">
        <button type="submit">submit doOther</button>
    </form>
    <br />

    <h3>请求中参数名和控制器一样</h3>
    <form action="single/receiveOne.do" method="post">
        name <input name="name" ><br />
        age  <input name="age" ><br />
        <button type="submit">submit receiveOne.do</button>
    </form>


    <br />
    <h3>请求中参数名和控制器不一样</h3>
    <form action="single/receiveOne2.do" method="post">
        name <input name="myName" ><br />
        age  <input name="myAge" ><br />
        <button type="submit">submit receiveOne2.do</button>
    </form>


    <br />
    <h3>使用java对象当请求参数</h3>
    <form action="single/receiveObject.do" method="post">
        name <input name="name" ><br />
        age  <input name="age" ><br />
        <button type="submit">submit receiveOne2.do</button>
    </form>

    <br />
    <h3>处理器返回String 表示视图名称</h3>
    <form action="returnParam/returnString.do" method="post">
        name <input name="name" ><br />
        age  <input name="age" ><br />
        <button type="submit">submit returnString.do</button>
    </form>


    <br />
    <button onclick="returnObject()" type="button"> 处理器返回object</button>

    <br />
    <button onclick="returnString()" type="button"> 处理器返回String</button>





</body>
</html>
